set more off

/* This file replicates the results in Table 6, Chegere, Eggert & Söderbom (CES) */ 

/*cd "C:\xxx....*/

discard 
clear all

use "CES2019_data.dta" 

keep if wave==1 & est_sample==1

/* this program uses wild bootstrap procedure for statistical tests */
prog def btf 
boottest {bagstreatment}{traintreatment}{bagstreatment=traintreatment}{sex}{age}{schooling}{activeworkers}{wealth}{maizeexperienceyears}{trained}, cluster (villagecode) reps(999) seed (906453) nogr
end

/* compute phmp index using pca */
pca harvestmatured immediatestorage maizesorted dryingperiod storedisinfected 
predict managpractindex2


/* Table 6: Effect of interventions on post-harvest management practices  */

foreach yvar in harvestmatured immediatestorage maizesorted dryingperiod storedisinfected managpractindex2 {
reg `yvar' bagstreatment traintreatment sex age schooling activeworkers wealth maizeexperienceyears trained, cluster(villagecode)
btf
}


/* Obtain p-values by means of randomised inference ("randomization-t randomized p-value") for treatment effects */
foreach yvar in harvestmatured immediatestorage maizesorted dryingperiod storedisinfected managpractindex2 {
randcmd ((bagstreatment traintreatment) reg `yvar' bagstreatment traintreatment sex age schooling activeworkers wealth maizeexperienceyears trained, cluster(villagecode)), treatvars(bagstreatment traintreatment)  groupvar(village)
}
